let form = document.querySelector('form');
let nameInp = document.querySelector('.username');
let ageInp = document.querySelector('.age');
let genderSel = document.querySelector('.gender');
let nickInp = document.querySelector('.nickname');


// fn()
// async function fn(){
//     let { status,info,id } = await isLogin();
//     if(status != 1){
//         location.href='./login.html';
//         return;
//     }

    console.log(info);
    nameInp.value = info.username;
    ageInp.value = info.age;
    nickInp.value = info.nickname;
    genderSel.value = info.gender;

    form.addEventListener('submit', async function (e){
        e.preventDefault();

        let data={ id };

        if(ageInp.value) data.age = ageInp.value;
        if(genderSel.value) data.gender = genderSel.value;
        if(nickInp.value) data.nickInp = nickInp.value;

        let r = await http.post('/users/update',data)
        if(r.data.code !=1) return alert('修改失败！请重试！！');

        alert('修改成功');
    })    
//}

